<?php
ob_start();
include("config.php");
include("header.php");
?>

<?php
include("code/databaseconnection.php");
?>
<form id="form1" name="form1" method="post" action="code/insert.php" >
  <table width="658" cellspacing="0" cellpadding="0">
    <tr>
      <td width="163">Title:</td>
      <td width="210"><select name="title"><option value="Mr">Mr</option><option value="Mrs">Mrs</option></select>		    </td>
      <td>Institution:</td>
    <td>
    <select name="Institutiontype"  >
    <option value='<?php  $Institutiontype ?>'><?php  $Institutiontype?></option>
    <?php
    $result=mysql_query("SELECT * FROM institution ");
	while ($row=mysql_fetch_array($result))
	{
		echo "<option value='".$row['INSTITUTION_NAME']."'>".$row['INSTITUTION_NAME']."</option>";
		
	}
	
    ?>
    </select>
    </td>
    </tr>
    
    
    <tr>
      <td width="163">First Name:</td>
      <td width="210"><input type="text" name="fname" size="30"  /></td>
    </tr>
    
    <tr>
    <td>Last Name:</td>
      <td><input type="text" name="Lname" size="30"/></td>
       <td>Designation</td>
    <td>
    <select name="Designationtype"  >
    <option value='<?php  $Designationtype ?>'><?php  $Designationtype?></option>
    <?php
    $result=mysql_query("SELECT * FROM designation ");
	while ($row=mysql_fetch_array($result))
	{
		echo "<option value='".$row['NAME_DESIGNATION']."'>".$row['NAME_DESIGNATION']."</option>";
		
	}
	
    ?>
    </select>
    </td>
    </tr>
    
   
    <tr>
      <td>Gender</td>
      <td><input type="radio" name="Gender" value="male" />Male <input type="radio" name="Gender" value="female" />				      Female</td>
    </tr>
    
    <tr>
      <td>Phone Number</td>
      <td><input type="text" name="PhoneNumber" size="30" /></td>
      <td>Edu_Qualification</td>
    <td>
    <select name="edu_qualification"  >
    <option value='<?php  $edu_qualification ?>'><?php  $edu_qualification?></option>
    <?php
    $result=mysql_query("SELECT * FROM edu_qualification ");
	while ($row=mysql_fetch_array($result))
	{
		echo "<option value='".$row['NAME_EDU_QUALIFICATION']."'>".$row['NAME_EDU_QUALIFICATION']."</option>";
		
	}
	
    ?>
    </select>
    </td>
    </tr>
    
    <tr>
      <td>Email</td>
      <td><input type="text" name="email" size="30" /></td>
      <td>Appointment Subject</td>
    <td>
    <select name="Subjecttype"  >
    <option value='<?php  $Subjecttype ?>'><?php  $Subjecttype?></option>
    <?php
    $result=mysql_query("SELECT * FROM appointment_subject ");
	while ($row=mysql_fetch_array($result))
	{
		echo "<option value='".$row['NAME_APPOINTMENT_SUBJECT']."'>".$row['NAME_APPOINTMENT_SUBJECT']."</option>";
		
	}
	
    ?>
    </select>
    </td>
    </tr>
    
    
    <tr>
      <td>ID Type</td>
      <td><input type="radio" name="ID_type" value="NIC" />NIC<input type="radio" name="ID_type" value="passport" />				      passport</td>
      <td width="172">Appointment Year:</td>
      <td width="111"><select name="Appointment_year">
      <option value="1980">1980</option>
      <option value="1981">1981</option>
      <option value="1982">1982</option>
      <option value="1983">1983</option>
      <option value="1984">1984</option>
      <option value="1985">1985</option>
      <option value="1986">1986</option>
      </select>	
    </td>
    </tr>
    <tr>
      <td>Id Number</td>
      <td><input type="text" name="Id_number" size="30" /></td>
      <td>Division</td>
    <td>
    <select name="divisiontype"  >
    <option value='<?php  $divisiontype ?>'><?php  $divisiontype?></option>
    <?php
    $result=mysql_query("SELECT * FROM division ");
	while ($row=mysql_fetch_array($result))
	{
		echo "<option value='".$row['NAME_DIVISION']."'>".$row['NAME_DIVISION']."</option>";
		
	}
	
    ?>
    </select>
    </td>
    </tr>
    
    
    
    <tr>
      <td>Address</td>
      <td><input type="text" name="Address" size="30" /></td><br />
	<td>Zone</td>
    <td>
    <select name="zonetype"  >
    <option value='<?php  $zonetype ?>'><?php  $zonetype?></option>
    <?php
    $result=mysql_query("SELECT * FROM zone ");
	while ($row=mysql_fetch_array($result))
	{
		echo "<option value='".$row['NAME_ZONE']."'>".$row['NAME_ZONE']."</option>";
		
	}
	
    ?>
    </select>
    </td>
    </tr>
    
    <tr>
      <td>Temporary_Address</td>
      <td><input type="text" name="Temporary_Address" size="30" /></td>
      <td>District</td>
    <td>
    <select name="Districttype"  >
    <option value='<?php  $Districttype ?>'><?php  $Districttype?></option>
    <?php
    $result=mysql_query("SELECT * FROM district ");
	while ($row=mysql_fetch_array($result))
	{
		echo "<option value='".$row['NAME_DISTRICT']."'>".$row['NAME_DISTRICT']."</option>";
		
	}
	
    ?>
    </select>
    </td>
    </tr>

     <tr>
      <td width="163">Office Email</td>
      <td width="210"><input type="text" name="office_email" size="30"  /></td>
    </tr>
    
    <tr>
    <td>Office Address</td>
      <td><input type="text" name="office_address" size="30"/></td>
    </tr>
    

    
    <tr>
      <td>Office Phone Number</td>
      <td><input type="text" name="office_phone_number" size="30" /></td>
    </tr>
    
    
    <tr>
      <td>&nbsp;</td>
      <td><input type="submit" name="insert" id="button" value="Submit" /></td>
    </tr>
    
    
  </table>

</form>
<?php
if($_GET['action']== "save")
{
	$g_title=$_POST['title'];
	$g_fname=$_POST['fname'];
	$g_lname=$_POST['Lname'];
	$g_email=$_POST['email'];
	$g_id_type=$_POST['ID_type'];
	$g_id_number=$_POST['Id_number'];
	$g_PhoneNumber=$_POST['PhoneNumber'];
	$g_Address=$_POST['Address'];
	
	$g_Temporary_Address=$_POST['Temporary_Address'];
	$g_Gender=$_POST['Gender'];
	echo $g_Institutiontype=$_POST['Institutiontype'];
	echo $g_Designationtype=$_POST['Designationtype'];
	echo $g_edu_qualification=$_POST['edu_qualification'];
	
	echo $g_Appointment_year=$_POST['Appointment_year'];
	echo $g_Subjecttype=$_POST['Subjecttype'];
	echo $g_divisiontype=$_POST['divisiontype'];
	echo $g_zonetype=$_POST['zonetype'];
	echo $g_Districttype=$_POST['Districttype'];
	$g_office_email=$_POST['office_email'];
	$g_office_address=$_POST['office_address'];
	$g_office_phone_number=$_POST['office_phone_number'];
	
	if($g_fname==""||$g_lname=="")
	{
		echo "first name or lanse name is blank";
	}
	else if( strpos($g_email,"@") < 1 || strpos($g_email,".") < 1 )
	{
		echo "Email Address is  error";
	}
	else if (strlen($g_id_number)!=10)
	{
		echo "error NIC nomber";
	}
		
	else {
		
		mysql_query("INSERT INTO participant   (TITLE,FIRST_NAME,LAST_NAME,EMAIL,ID_TYPE,ID_NUMBER,PHONE_NUMBER,TEMPORARY_ADDRESS,ADDRESS,GENDER,INSTITUTION,DESIGNATION,EDU_QUALIFICATION,APPOINTMENT_YEAR,APPOINTMENT_SUBJECT,DIVISION,ZONE,DISTRICT,OFFICE_EMAIL,OFFICE_ADDRSS,OFFICE_PHONE_NUMBER ) VALUES('$g_title','$g_fname','$g_lname','$g_email','$g_id_type','$g_id_number','$g_PhoneNumber','$g_Temporary_Address','$g_Address','$g_Gender','$g_Institutiontype','$g_Designationtype','edu_qualification','$g_Appointment_year','$g_Subjecttype','$g_divisiontype','$g_zonetype','$g_Districttype','$g_office_email','$g_office_address','$g_office_phone_number') ") or die(mysql_error());
		
		echo "registed";
		session_start();
			$_SESSION['user']=$g_fname;
			$_SESSION['userid']=$row['ID'];
			header("location:userregedu.php");
			exit;
	}
	
}
?>

<?php
include("fooder.php");
	
?>